package com.mpsc.seata.provite.service.impl;

import com.mpsc.api.bean.UserInfoEntity;
import com.mpsc.seata.provite.dao.UserInfoDao;
import com.mpsc.seata.provite.service.UserInfoService;
import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoDao userInfoDao;

    @Override
    @GlobalTransactional
    public void saveUserInfo(UserInfoEntity user) {
        System.out.println("-------执行saveUserInfo()方法之前-------");
        //  user.setId(user.getId() + 1);
        userInfoDao.saveUserInfo(user);
        System.out.println("-------执行saveUserInfo()方法之后-------");
        //throw new RuntimeException("测试seata回滚问题!!!");
    }

    @Override
    public UserInfoEntity findUserById(long id) {
        return userInfoDao.findUserById(id);
    }

    @Override
    public void updateUserInfo(UserInfoEntity user) {
        userInfoDao.updateUserInfo(user);
    }
}
